var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, app = getApp();
let interstitialAd = null;

Page({
    data: {
        token: wx.getStorageSync("token"),
        share: {
            text: "",
            xcx_title: "",
            share_image: "",
            member_id: ""
        }
    },
    onLoad: function(t) {
        that = this;
    },
    onReady: function() {
    },
    onShow: function() {
        var t = {
            action: "index",
            contr: "my",
            token: wx.getStorageSync("token")
        };
        _tools2.default.request(t, function(t) {
            that.setData(t.info);
        }), wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });

        console.log(this.data)
        if (wx.createInterstitialAd) {
            interstitialAd = wx.createInterstitialAd({
              adUnitId: 'adunit-42e141bfcfdcc315'
            })
            interstitialAd.onLoad(() => {})
            interstitialAd.onError((err) => {})
            interstitialAd.onClose(() => {})
          };
          
          // 在适合的场景显示插屏广告
          if (interstitialAd) {
            interstitialAd.show().catch((err) => {
              console.error(err)
            })
          };
    },
    gotoCash: function() {
        wx.navigateTo({
            url: "/bh_bargain/pages/cash/cash"
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_bargain/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    getUserInfo: function(t) {
        console.log("getUserInfo",t)
        if ("getUserInfo:ok" == t.detail.errMsg) {
            var e = {
                action: "register",
                contr: "my",
                token: wx.getStorageSync("token"),
                encryptedData: t.detail.encryptedData,
                iv: t.detail.iv
            };
            _tools2.default.request(e, function(t) {
                that.onReady();
            });
        }
    }
});